﻿namespace Skymate.Commands
{
    using System.ComponentModel;

    /// <summary>
    /// 车道
    /// </summary>
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class VehicleLane
    {
        public VehicleLane(VehicleLaneTypeEnum type, int laneNumber)
        {
            this.Type = type;
            this.LaneNumber = laneNumber;
        }

        /// <summary>
        /// 车道类型
        /// </summary>
        [Description("车道类型")]
        public VehicleLaneTypeEnum Type { get;  set; }

        /// <summary>
        /// 车道号
        /// </summary>
        [Description("车道号")]
        public int LaneNumber { get;  set; }

        public static VehicleLane Create(byte value)
        {
            return
            new VehicleLane((VehicleLaneTypeEnum)(value >> 4), laneNumber: value & 0x0F);
        }

        public byte ToByte()
        {
            return (byte)(((byte)this.Type << 4) | this.LaneNumber);
        }
    }
}